package sb.simple.wrapper.common;


import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    //private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);


    @ExceptionHandler(value = CustomException.class)
    public CommonResult customExceptionHandler(CustomException exception) {
        System.out.println("customExceptionHandler:" + exception);
        return CommonResult.defineFailure(exception);
    }


    @ExceptionHandler(value = Exception.class)
    public CommonResult otherExceptionHandler(Exception exception) {
        System.out.println("otherExceptionHandler:" + exception);
        return CommonResult.otherFailure(OtherErrorEnum.INTERNAL_SERVER_ERROR);
    }

}
